package top.tagao.yygh.hosp.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
import top.tagao.yygh.common.result.Result;
import top.tagao.yygh.hosp.service.HospitalService;
import top.tagao.yygh.model.hosp.Hospital;
import top.tagao.yygh.vo.hosp.HospitalQueryVo;

import java.util.Map;

/**
 * @author fu-xiao-liu
 * @Date 2022/3/5 20:58
 */

@Api(tags = "医院管理接口")
//@CrossOrigin
@RestController
@RequestMapping("/admin/hospital/hospital")
public class HospitalController {

    @Autowired
    HospitalService hospitalService;



    @ApiOperation(value = "医院列表(条件查询分页)")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page,
                           @PathVariable Integer limit,
                           HospitalQueryVo hospitalQueryVo) {
        Page<Hospital> pageModel = hospitalService.selectHospPage(page,limit,hospitalQueryVo);


        return Result.ok(pageModel);
    }

    @ApiOperation(value = "修改医院上线情况")
    @GetMapping("updateHospStatus/{id}/{status}")
    public Result updateHospitalStatus(  @ApiParam(name = "id", value = "医院id", required = true)
                                             @PathVariable("id") String id,
                                         @ApiParam(name = "status", value = "状态（0：未上线 1：已上线）", required = true)
                                             @PathVariable("status") Integer status) {
         hospitalService.updateHospitalStatus(id,status);
        return Result.ok();
    }

    @ApiOperation(value = "根据id查询医院详情")
    @GetMapping("getHospitalById/{id}")
    public Result getHospitalById(  @ApiParam(name = "id", value = "医院id", required = true)
                                         @PathVariable("id") String id) {
        Map<String,Object> map = hospitalService.getHospitalById(id);
        return Result.ok(map);
    }

}
